package com.sky.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;

@Configuration
 public class ExecturConfig {
   @Bean("taskExector")
   public Executor taskExector() {
     ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
     executor.setCorePoolSize(3);//核心池大小
     executor.setMaxPoolSize(5);//最大线程数
     executor.setQueueCapacity(3);//队列长度
     executor.setKeepAliveSeconds(10);//线程空闲时间
     executor.setThreadNamePrefix("tsak-asyn");//线程前缀名称
     executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());//配置拒绝策略
     return executor;
   }
 }